package com.ruoyi.deviceM.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.deviceM.mapper.UserDeviceMapper;
import com.ruoyi.deviceM.domain.UserDevice;
import com.ruoyi.deviceM.service.IUserDeviceService;
import com.ruoyi.common.core.text.Convert;

/**
 * 设备信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-08-07
 */
@Service
public class UserDeviceServiceImpl implements IUserDeviceService 
{
    @Autowired
    private UserDeviceMapper userDeviceMapper;

    /**
     * 查询设备信息
     * 
     * @param deviceId 设备信息主键
     * @return 设备信息
     */
    @Override
    public UserDevice selectUserDeviceByDeviceId(Long deviceId)
    {
        return userDeviceMapper.selectUserDeviceByDeviceId(deviceId);
    }

    /**
     * 查询设备信息列表
     * 
     * @param userDevice 设备信息
     * @return 设备信息
     */
    @Override
    public List<UserDevice> selectUserDeviceList(UserDevice userDevice)
    {
        return userDeviceMapper.selectUserDeviceList(userDevice);
    }

    /**
     * 新增设备信息
     * 
     * @param userDevice 设备信息
     * @return 结果
     */
    @Override
    public int insertUserDevice(UserDevice userDevice)
    {
        userDevice.setCreateTime(DateUtils.getNowDate());
        return userDeviceMapper.insertUserDevice(userDevice);
    }

    /**
     * 修改设备信息
     * 
     * @param userDevice 设备信息
     * @return 结果
     */
    @Override
    public int updateUserDevice(UserDevice userDevice)
    {
        userDevice.setUpdateTime(DateUtils.getNowDate());
        return userDeviceMapper.updateUserDevice(userDevice);
    }

    /**
     * 批量删除设备信息
     * 
     * @param deviceIds 需要删除的设备信息主键
     * @return 结果
     */
    @Override
    public int deleteUserDeviceByDeviceIds(String deviceIds)
    {
        return userDeviceMapper.deleteUserDeviceByDeviceIds(Convert.toStrArray(deviceIds));
    }

    /**
     * 删除设备信息信息
     * 
     * @param deviceId 设备信息主键
     * @return 结果
     */
    @Override
    public int deleteUserDeviceByDeviceId(Long deviceId)
    {
        return userDeviceMapper.deleteUserDeviceByDeviceId(deviceId);
    }
}
